#include <bits/stdc++.h>
using namespace std;
int T;
int n,m,L,V;
int cntcar;
int cntm;
vector <pair<double,double> >car;
int mdis[100005];
vector <int>mtocar[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    double di,vi,ai;
    double dleft,dright;
    bool overspeed;
    for(int i=1;i<=T;i++){
        cntcar=0;
        cntm=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            overspeed=false;
            cin>>di>>vi>>ai;
            if(vi>V){
                dleft=di;
                overspeed=true;
            }
            //vi<V
            else{
            if(ai>0){
                dleft=di+(pow(V,2)-pow(vi,2))/(2*ai);
                if(dleft<L)overspeed=true;
            }
            }
            if(overspeed){
                if(ai<0)dright=di+(pow(V,2)-pow(vi,2))/(2*ai);
                else dright=L+1;
                car.push_back(make_pair(dleft,dright));
                cntcar++;
            }
        }
        for(int i=1;i<=m;i++){
            cin>>mdis[i];
            for(int j=0;j<cntcar;j++){
                if(car[j].first<=mdis[i]&&car[j].second>mdis[i])mtocar[i].push_back(j);
            }
            if(mtocar[i].empty())cntm++;
        }

    cout<<cntm<<endl;


    }

    return 0;
}
